#!/usr/bin/env python
"""An example script that uses MainKit

'city', 'state', and 'country' are ordered arguments
'country' is optional

if a long description is set to a case-insensitive match to itself, no default
is set.

usage: %prog [options] city state [country]
    -i, --interact : interactive mode 
    -o, --out=red: print out
    -1, --option1=OPTION1: print option1 
    -2, --option2=OPTION2: print option2 """
    
import sys
import fimero.core.util.OptionKit as OptionKit
import fimero.core.util.MainKit as MainKit

class TScript(MainKit.TMain):

    def _execute(self, options, args):

        # evaluate the options and arguments that have been
        # supplied. if they are not valid, call OptionKit.abort()
        print options
        print args

        if len(args) == 1:
            OptionKit.abort()

    def _make_option_parser(self):

        # customize the parser with any additional restrictions
        parser = OptionKit.parse(__doc__)

        choices = ["red", "green", "blue"]        
        OptionKit.restrict_option(parser.get_option("-o"), choices)

        return parser

    def __init__(self):    
        MainKit.TMain.__init__(self)
        self.arg_list = ['arg1', 'arg2']        


SCRIPT = TScript()

if __name__ == "__main__":
    sys.exit(SCRIPT.main())
